def index_error(a):
    #索引越界异常
    try:
        lst=[3,2,5]
        rest = lst[a]
    except IndexError as e:
        print(e,type(e))
        
def key_error(name): #字典错误
    ages = {
        "zhs":6,
        "ls":5
    }
    try:
        print(ages[name])
    except KeyError as e:
        print(e,type(e))
        
def value_error(): #值错误
    num_str = "123abc"
    try:
        num = int(num_str)
        print(num)
    except ValueError as e:
        print(e,type(e))
        
class person(object):
    def __init__(self,name):
        self.name = name
        
def sttr_error():
    p = person("zs")
    try:
        print(p.name)
        print(p.age)
        print(p.say())
    except AttributeError as e:
        print(e,type(e))
if __name__ == '__main__':
    index_error(5)
    key_error("ww")
    value_error()
    sttr_error()